using System.Reflection;

namespace Oomf
{
    public class PropertyConversion<TSource, TResult> where TResult : new()
    {
        private readonly Mapper mapper;

        public PropertyConversion(Mapper mapper)
        {
            this.mapper = mapper;
        }

        public TResult Do(TSource source)
        {
            var result = new TResult();
            PropertyInfo[] propertyInfos = typeof (TSource).GetProperties(OomfBindingFlags.BindingFlags);

            foreach (var propertyInfo in propertyInfos)
            {
                Property property = new Property(propertyInfo);
                if (!property.SetProperty(source, result))
                    property.SetField(source, result);
            }
            return result;
        }
    }
}